package com.dly.hope.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;

/**
 * @author linyu.dai
 * @project myserve
 * @description
 * @creat 2022/11/17 15:00:34
 */
@Configuration
public class LuaConfig {

    @Bean
    public DefaultRedisScript<Long> stockScript(){
        DefaultRedisScript<Long> stockScript = new DefaultRedisScript<>();
        //加载lua脚本 实现redis命令原子性
        stockScript.setLocation(new ClassPathResource("lua/temp.lua"));
        //设置返回值类型
        stockScript.setResultType(Long.class);
        return stockScript;
    }
}
